package com.learncloud.common.config;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.learncloud.service.IFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * <p>
 * amqp 消费者
 * <p/>
 *
 * @author : yj
 */
@Component
@Slf4j
public class FileRabbitListenerConfig {

    @Autowired
    private IFileService iFileService;

    public void mergeAndTranscode(String string) {
//        FileResourceInfo fileResourceInfo = JSONObject.parseObject(string, FileResourceInfo.class);
//        ResponseWrap responseWrap = ResponseWrapUtil.error("error",fileResourceInfo);
//        if (fileResourceInfo != null && !StringUtils.isEmpty(fileResourceInfo.getUrl())){
//            try {
//                VideoMetaInfo videoMetaInfo = iFileService.mergeAndTranscode(fileResourceInfo.getUrl(),fileResourceInfo.getContentType().split("/")[1]);
//                if (videoMetaInfo != null) {
//                    fileResourceInfo.setUrl(videoMetaInfo.getUrl());
//                    fileResourceInfo.setBucketName(videoMetaInfo.getBucketName());
//                    fileResourceInfo.setObjectName(videoMetaInfo.getObjectName());
//                    responseWrap = ResponseWrapUtil.success(fileResourceInfo);
//                }
//            }catch (Exception e){
//                log.error("视频转码错误{},资源id:{}",e.getMessage(),fileResourceInfo.getRelationId());
//            }
//        }
    }

}
